<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>donw2-下载并运行</title>
    <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript" src="js/down.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/demo.js" charset="utf-8"></script>
    <style type="text/css">
        h5 {margin:0;}
        p {font: 9pt 宋体;}
        ul {list-style-type: none;font: 9pt 宋体;}
        ul li {display: inline;margin: 0 5px 0 0;font: 9pt 宋体;}
    </style>
</head>
<body>
<h5>下载后自动运行</h5>
<div id="demos"></div>
<input type="button" value="下载文件并安装" id="btn-down-run" />
<div id="downDiv"></div>
<script type="text/javascript" language="javascript">
    //根路径：http://localhost/api/up6/
    var pos = window.location.href.lastIndexOf("down-run.htm");
    var api = window.location.href.substr(0, pos)+"db/";
    var downer = new DownloaderMgr({
        config: {
            License2:"",//请在此处配置授权码
            Folder: "",
            DataBase: false,//启用数据库支持
            //api
            "UrlCreate": api + "d_create.jsp",
            "UrlDel": api + "d_del.jsp",
            "UrlList": api + "d_list.jsp",
            "UrlUpdate": api + "d_update.jsp",
            "UrlDown": api + "down.jsp"
        },
        event: {
            taskCreate: function (f) {
                $(document.body).append("文件ID：" + f.fileSvr.id) + "<br/>";

                setTimeout(function () {
                    if (f.fields.auto=="1") downer.start_queue();
                }, 300);
            },
            downProcess: function (obj) { },
            downStoped: function (obj) { },
            downComplete: function (obj) {
                $(document.body).append('<div>本地路径：' + obj.fileSvr.pathLoc + '</div>');
            },
            downError: function (obj, err) { },
            queueComplete: function () {
                $(document.body).append("<div>队列完成</div>");
            },
            //ready: function () { },
            selFolder: function (dir) {
                setTimeout(function(){
                    if(downer.data.cur!=null)
                    {
                        downer.addUrl(downer.data.cur);
                        downer.data.cur = null;
                    }
                },100);
            }
        },
        ui: { render:"downDiv"}
    });

    $(function () {
        $("#btn-down-run").click(function () {
            var f = { fileUrl: "http://localhost:8080/down2/test.exe" ,fields:{auto:"1"}};

            if (downer.Config["Folder"] == "") {
                downer.data.cur = f;
                downer.openFolder();
                return;
            }

            downer.addUrl(f);
        });
    });
</script>
</body>
</html>